import { Component } from '@angular/core';
import {  NavController, NavParams,ViewController } from 'ionic-angular';
import { InAppBrowser } from '@ionic-native/in-app-browser';
/**
 * Generated class for the OpenurlPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */


@Component({
  selector: 'page-openurl',
  templateUrl: 'openurl.html',
})
export class OpenurlPage {
  public chooseType='handle';
  public goUrl='www.baidu.com';
  public showArr=[
   {
     text:'1.ionic cordova plugin add cordova-plugin-inappbrowser',
     tips:'安装cordova'
   },{
     text:' 2.cnpm install --save @ionic-native/in-app-browser',
     tips:'安装依赖'
    },{
      text:"import { InAppBrowser  } from '@ionic-native/in-app-browser';",
      tips:'添加到应用模块'
    }
  ]
  constructor(public navCtrl: NavController, public navParams: NavParams,
   public viewCtrl:ViewController,private iab: InAppBrowser) {
  }


  dismiss(){
    this.viewCtrl.dismiss();
  }
  goOutUrl(){
    let url=this.goUrl;
    const browser = this.iab.create('https://'+url);

browser.on('loadstop').subscribe(event => {
   browser.insertCSS({ code: "body{color: red;" });
});

// browser.close();
  }
  segmentChanged(e){
    console.log(e)
    console.log(this.chooseType)
  }
  ionViewDidLoad() {
    console.log('ionViewDidLoad OpenurlPage');
  }

}
